<#-- 导入模版定义文件-->
<#include "../template/template_listPage.ftl">
<@header title="卡密产品管理">
<style type="text/css">
    .table {
        padding: 1px;
        text-align: center;
    }
</style>
<script type="text/javascript">
    function query() {
        $('#listForm').submit();
    }
    $(document).ready(function () {
        $('#province').change(function () {
            var proviceCode = $('#province').val();
            loadArea(proviceCode, 'areaCity', '2', true);
        });
        loadArea('', 'province', '1', true);
    });
    function loadArea(parentCode, id, grade, isTip) {
        if (parentCode == undefined) {
            parentCode = '';
        }
        if (grade == undefined) {
            grade = '';
        }
        if (parentCode == '' && grade == '') {
            return;
        }
        $.ajax({
            type:"POST",
            url:"${web_base}/recharge/area!loadArea.htm",
            async:false,
            data:"parentCode=" + parentCode + '&grade=' + grade,
            success:function (data) {
                var dataObj = eval("(" + data + ")");
                var html = '';
                var isProvice = false;
                $.each(dataObj, function (i, n) {
                    html = html + '<option value="' + n.code + '">' + n.areaName + '</option>';
                    if (n.grade == 1) {
                        isProvice = true;
                    }
                });
                if (isProvice) {
                    html = '<option value="">--请选择省份--</option>' + html;
                } else {
                    html = '<option value="">--请选择城市--</option>' + html;
                }

                $('#' + id).html(html);
            }
        });
    }
</script>
<script type="text/javascript">
    $().ready(function () {

        var $validateErrorContainer = $("#validateErrorContainer");
        var $validateErrorLabelContainer = $("#validateErrorContainer ul");
        var $validateForm = $("#validateForm");
        var $tab = $("#tab");

        // Tab效果
        $tab.tabs(".tabContent", {
            tabs:"input"
        });

        // 表单验证
        $validateForm.validate({
            errorContainer:$validateErrorContainer,
            errorLabelContainer:$validateErrorLabelContainer,
            wrapper:"li",
            errorClass:"validateError",
            ignoreTitle:true,
            rules:{
                "upload":{
                    required:true
                },
                "operatorsType":{
                    required:true
                },
                "phoneType":{
                    required:true
                }
            },
            messages:{
                "upload":{
                    required:"请选择一个卡密文件"
                },
                "operatorsType":{
                    required:"请选择一个运营商"
                },
                "phoneType":{
                    required:"请选择号码类型"
                }
            },
            submitHandler:function (form) {
                $(form).find(":submit").attr("disabled", true);
                form.submit();
            }
        });
		<#if actionErrors??&&(actionErrors?size > 0)>
			$.dialog({type: "warn", content: "<#list errorMessages as list>${list}<br></#list>",
			 modal: true, autoCloseTime: 3000});
		</#if>
    });
</script>
</@header>
<body class="list">
<div class="body">
    <div class="listBar">
        <h1><span class="icon">&nbsp;</span>您当前的位置:&nbsp;<span class="pageInfo">[卡密库存导入]</span></h1>
    </div>
    <div style="display: none;" id="validateErrorContainer" class="validateErrorContainer">
        <div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
        <ul></ul>
    </div>
    <form action="${web_base}/recharge/card_import!doLeadin.htm"
          enctype="multipart/form-data" method="post" id="validateForm">
        <div style="margin-left: 30px;">
            <table class="listTable">
                <tr>
                    <td><span class="sort">库存产品:</span><input type="hidden" name="cardName" value="${cardName!}"></td>
                    <td>${cardName!}</td>
                </tr>
                <tr>
                    <td>导入数据源:</td>
                    <td><input type="file" name="upload"/>
                        <input type="hidden" name="title"/></td>
                </tr>
                <tr>
                    <td>资源商:</td>
                    <td><select name="">
                        <option value="0">本单位</option>
                    </select></td>
                </tr>
                <tr>
                    <td>运营商:</td>
                    <td><select name="operatorsType">
                        <option value="">请选择</option>
                    <#if operationList??>
                        <#list operationList as obj>
                            <option value="${obj.code}">${obj.name!}</option>
                        </#list>
                    </#if>
                    </select></td>
                </tr>
                <tr>
                    <td>号码类型:</td>
                    <td><select name="phoneType">
                        <option value="">请选择</option>
                    <#if phoneTypeList??>
                        <#list phoneTypeList as obj>
                            <option value="${obj.code}">${obj.name!}</option>
                        </#list>
                    </#if>
                    </select></td>
                </tr>
                <tr>
                    <td>可充区域:</td>
                    <td><select name="province" id="province">
                        <option value="">--请选择省份--</option>
                    </select><select name="areaCity" id="areaCity">
                        <option value="">--请选择城市--</option>
                    </select></td>
                </tr>
                <tr>
                    <td>有无有效期:</td>
                    <td><input type="checkbox" name="iseffect" checked="checked" value="0">无(没有有效期,系统默认在当前时间加两年的有效期)
                    </td>
                </tr>
                <tr>
                    <td>进货源:</td>
                    <td><select name="supplier">
                    <#if stockSuppliersList??>
                        <#list stockSuppliersList as obj>
                            <option value="${obj.id!}">${obj.name!}</option>
                        </#list>
                    </#if>
                    </select></td>
                </tr>
            <#--        <tr>
               <td>进货日期:</td>
               <td><input type="text" name="supplyDate" onclick="WdatePicker({readOnly:true});" class="Wdate"></td>
           </tr> -->
                <tr>
                    <td>使用级别:</td>
                    <td><select name="useLevel" id="">
                        <option value="5">5</option>
                        <option value="4">4</option>
                        <option value="3">3</option>
                        <option value="2">2</option>
                        <option value="1">1</option>
                    </select></td>
                </tr>
            </table>
        </div>
        <div style="text-align: center;">
            <input type="submit" value="导入">
            <input type="button" onclick="history.go(-1);" value="返回产品清单">
        </div>
    </form>
    <div class="foot" style="margin-left: 30px;padding-bottom: 20px;">
        <p>
            <span>导入说明:</span> <br>
            1:导入分两种格式(<span>卡号,密码,面值</span>)和(卡号,密码,面值,有效期) <br>
            2:导入以文本文件框式,卡与卡之间使用回车来区分,上述参数使用tab键区分<br>
            3:卡号与密码为字母+数字组合,金额为整形数值,有效期日期格式为YYYY-MM-DD(例:2100-10-10)<br>
            4:可充区域的省和市均为可选项
        </p>
    </div>
</div>
</body>
</html>